//
//  MainTabbarController.swift
//  amicool
//
//  Created by mario-yc on 2017/6/13.
//  Copyright © 2017年 mario-yc. All rights reserved.
//

import UIKit
class MainTabbarController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        //从故事版中取得视频主页对应的导航控制器即可
        let videoStoryboard = UIStoryboard(name: "Video", bundle: nil)
        let videoNavController = videoStoryboard.instantiateViewController(withIdentifier: "videoNav")
        //调用meviewcontroller
        let me = MeViewController()
        
        self.viewControllers = [videoNavController,me]
        
        
        let tabBarItemTieles:[String] = ["视频","我"]
        
        let tabBarItemImages:[String] = ["video","me"]
        
        //设置tabBar
        let tabBar = self.tabBar
        self.tabBar.frame = CGRect(x: tabBar.frame.minX, y:tabBar.frame.minY,width: tabBar.frame.width, height:50)
        
        var index = 0
        for item in self.tabBar.items!{
            //设置 标题
            item.title = tabBarItemTieles[index]
            //设置 图标
            let selectedImage = UIImage(named: String(format: "%@.png", tabBarItemImages[index]))?.scaleImageToSize(CGSize(width: 25, height: 25))
            
            let unselsectedImage = UIImage(named: String(format: "%@-2.png", tabBarItemImages[index]))?.scaleImageToSize(CGSize(width: 25, height: 25))
            item.image = selectedImage
            item.selectedImage = unselsectedImage
            
            index += 1
        }
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    };}
